Imports System.Windows.Forms
Imports System.Security.Permissions

<Assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, Unrestricted:=True)> 
'<Assembly: UIPermission(SecurityAction.RequestOptional, Unrestricted:=True)> 

Public Class Settings

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    <UIPermission(SecurityAction.PermitOnly, Unrestricted:=True)> _
    Private Sub Settings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Me.txtRSWebService.Text = My.Settings.ReportServerWebService
            Me.txtPollTime.Text = CInt(My.Settings.PollTime / 1000)
        Catch ex As Exception
            MsgBox("Settings could not be loaded." & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "RSJM Settings")
            Me.Close()
        End Try
    End Sub

    Private Sub txtPollTime_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPollTime.TextChanged
        If Integer.TryParse(Me.txtPollTime.Text, New Integer) Then
            If CInt(Me.txtPollTime.Text) > 0 Then
                Me.lblError.Visible = False
                Me.OK_Button.Enabled = True
            Else
                Me.lblError.Visible = True
                Me.OK_Button.Enabled = False
            End If
        Else
            Me.lblError.Visible = True
            Me.OK_Button.Enabled = False
        End If
    End Sub
End Class
